import {generateRuntimeCheckCode} from "../src/generateRuntimeCheckCode.js";

const runtimeAppId = "wxabc";
const result = generateRuntimeCheckCode(runtimeAppId, {
    release: true
});

const code = result.minify;
console.log(code)
console.log(result.code)

const cc = {
    sys: {
        platform: 1,
        Platform: {
            WECHAT_GAME: 1
        }
    }
}


eval(`
    let right = true;
    const GameGlobal = {
        wx: {
            getAccountInfoSync() {
                return {
                    miniProgram: {
                        appId: runtimeAppId + "error",
                        envVersion: "release"
                    }
                }
            }
        }
    }
    const Math = {
        random(){
            return 0.01
        }
    }

    function test() {
        ${code}
        right = false;
        console.log("if you see this, your generate code is error")
    }
    test();
    console.assert(right, "被弄了情况 没能正确")
`);



eval(`
    let right = false;
    const GameGlobal = {
        wx: {
            getAccountInfoSync() {
                return {
                    miniProgram: {
                        appId: runtimeAppId
                    }
                }
            }
        }
    }
    const Math = {
        random(){
            return 0.01
        }
    }


    function test() {
        ${code}
        right = true;
    }
    test();

    console.assert(right, "正常情况不能运行")
`);
